<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<div class="project_contents">
	<h1>Gantt Chart</h1>
	<div class="project_in">
		<input type="button" class="btn" onclick="get_ganttChangeYear(${calendar.currentYear -1})" value="이전" />
		<span class="">${calendar.currentYear } 년 </span>
		<input type="button" class="btn" onclick="get_ganttChangeYear(${calendar.currentYear +1})" value="이후" />
		<input type="button" class="btn" onclick="get_gantt(${calendar.currentYear},${calendar.currentMonth })"
			value="월간" />
		<table id="gantt_table">
			<tr>
				<th id="work_name"></th>
				<c:set var="months" value="1" />
				<c:forEach var="lastDay" items="${lastDay }">
					<th class="work_month" colspan=${lastDay }><input type="button"
						onclick="get_gantt(${calendar.currentYear}, ${months-1})"
						value="${months}월" /></th>
					<c:set var="months" value="${months+1 }" />
				</c:forEach>
			</tr>
			<c:forEach var="work" items="${workList }">
				<tr>
				<c:if test="${work.workDeadTime.getYear()-100>= calendar.currentYear-2000 && work.workStartTime.getYear()-100<=calendar.currentYear-2000}">
					
						<th id="work_name" onclick="pick_work(${work.workNo})">${work.workTitle}</th>
				</c:if>
				<c:forEach begin="1" end="365" var="day">
					<c:if test="${work.workDeadTime.getYear()-100>= calendar.currentYear-2000 && work.workStartTime.getYear()-100<=calendar.currentYear-2000}">
						<c:choose>
							<c:when test="${work.startDate<=day && work.deadDate>=day }">
								<td id="ganttcolor"><p></p></td>
							</c:when>
							<c:otherwise>
								<td id="ganttcolor"></td>
							</c:otherwise>
						</c:choose>
					</c:if>
				</c:forEach>
				</tr>
			</c:forEach>
		</table>
	</div>
</div>
<script>
function get_ganttChangeYear(year)
{
	$('.project_contents').load('project/gantt/changeYear', {
		year : year
	});
}

function get_gantt(year, month) {
	$('.project_contents').load('project/gantt/changeMonth', {
		year : year,
		month : month
	});
}
</script>

